package com.headwind.repository;

import com.headwind.entity.HwUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @author : Headwind
 * @version : 1.0
 * @date : Created in 2020/8/15
 * @description : 用户类接口方法
 */
@Repository
public interface HwUserRepository extends JpaRepository<HwUser, String> {
    /**
     * 根据姓名查询用户
     *
     * @param name 名字
     * @return 用户信息
     */
    @Query(value = "select u from hw_user u where u.name = :name")
    HwUser findByName(@Param("name") String name);

    /**
     * 根据邮箱查询用户信息
     *
     * @param mail 邮箱地址
     * @return 用户信息
     */
    @Query(value = "select * from hw_user where mail = ?1", nativeQuery = true)
    HwUser findByMail(String mail);
}
